package data_structure;

public class leetcode_0226 {
    public TreeNode invertTree(TreeNode root) {
        if(root==null) return root;
        reverse(root);
        return root;
    }
    public void reverse(TreeNode node){
        TreeNode tmp=node.left;
        node.left=node.right;
        node.right=tmp;
        if(node.left!=null){
            reverse(node.left);
        }
        if(node.right!=null){
            reverse(node.right);
        }
    }
}
